#include "HartGlbPure.h"
#include <Windows.h>
#include <string>
#include <locale>
#include <codecvt>


void swap16(unsigned short *swap)
{
	if(swap == nullptr)
	{
		return;
	}

	BYTE byLo = LOBYTE(*swap);
	BYTE byHi = HIBYTE(*swap);

	*swap = MAKEWORD(byHi, byLo);
}

void swap32(unsigned long *swap)
{
	if(swap == nullptr)
	{
		return;
	}

    unsigned short wdLo = LOWORD(*swap);
    unsigned short wdHi = HIWORD(*swap);
	swap16(&wdLo);
	swap16(&wdHi);

	*swap = MAKELONG(wdHi, wdLo);
}



//convert string to wstring
std::wstring StringToWstring(const std::string& input)
{
    std::wstring_convert<std::codecvt_utf8<wchar_t>> converter;
    return converter.from_bytes(input);
}

std::string WstringToString(const std::wstring& wstr) {
	std::wstring_convert<std::codecvt_utf8<wchar_t>> converter;
	return converter.to_bytes(wstr);
}

